package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Product;
import cn.wolfcode.trip.base.query.ProductQueryObject;
import cn.wolfcode.trip.base.service.IProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("products")
public class ProductController {

    @Autowired
    private IProductService productService;

    /**
     * 根据类型获取相关商品
     * @param qo
     * @return
     */
    @GetMapping
    public PageInfo getProductsByType(ProductQueryObject qo){

        PageInfo pageInfo = productService.getProductByType(qo);
        return pageInfo;
    }

    @GetMapping("getProductById")
    public Product getProductById(Long id){
        Product product = productService.selectByPrimaryKey(id);
        return product;
    }



}
